//
//  MainNavigationController.swift
//  DouYuZB
//
//  Created by 中创 on 2020/4/26.
//  Copyright © 2020 梁森. All rights reserved.
//

import UIKit

class MainNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        addPangesture()
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        viewController.hidesBottomBarWhenPushed = true
        super.pushViewController(viewController, animated: true)
    }

}

extension MainNavigationController{
    /// 全屏返回手势
    fileprivate func addPangesture(){
        guard let systemGesture = interactivePopGestureRecognizer else {return}
        guard let getstureView = systemGesture.view else {return}
        let targets = systemGesture.value(forKey: "_targets") as? [NSObject]
        guard let targetObjct = targets?.first else {return}
        guard let target = targetObjct.value(forKey: "target") else {return}
        print(targetObjct)
        let action = Selector(("handleNavigationTransition:"))
        let panGesture = UIPanGestureRecognizer(target: target, action: action)
        getstureView.addGestureRecognizer(panGesture)
    }
}
